package com.agp.com.agp.web;

/**
 * Created by anguangpei on 2018/10/28.
 */

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * 访问客户端示例
 * @author oKong
 *
 */
@RestController
@Slf4j
public class DemoController {

    @Autowired
    RestTemplate restTemplate;

    @GetMapping("/hello")
    public String hello(String name) {
        //直接使用服务名进行访问
        log.info("请求参数name:{}", name);
        return restTemplate.getForObject("http://eureka-client/hello?name=" + name, String.class);
    }
}
